import React, { Component, forwardRef } from 'react'
//穿透性强大的ref函数
export default class App extends Component {
    mytext = React.createRef()
    render() {
        return (
            <div>
                <button onClick={() => {
                    this.mytext.current.foucs()
                }}>获取焦点</button>
                <Child ref={this.mytext}></Child>
            </div>
        )
    }
}

//一定要函数式
const Child = forwardRef((props, ref) => {
    return <div>
        <input defaultValue={11} ref={ref}></input>
    </div>
})